package io;

import java.io.*;

public class CharacterStreamTest {
    public static void main(String[] args) {
        File file = new File("D:\\test\\Test.txt");
        try {
            FileReader fileReader = new FileReader(file);
//            BufferedReader bufferedReader = new BufferedReader(fileReader);
//            int count = bufferedReader.read();
            FileWriter fileWriter = new FileWriter(file,true);
            String writer = "我不喜欢这世界\r\n我只喜欢你\r\n";
            char[] chars = writer.toCharArray();
            char[] c = new char[1024];
            int count = fileReader.read(c);
            while (count != -1){
                String s = new String(c,0,count);
                System.out.print(s);
                count = fileReader.read(c);
            }
            fileReader.close();
            CharSequence seq = new String(chars);
            fileWriter.append(seq);
            fileWriter.flush();
        } catch (java.io.IOException e) {
            e.printStackTrace();
        } finally {

        }
    }

}
